package com.examsystem.util;

import org.springframework.stereotype.Component;

/**
 * @author Administrator
 */
@Component
public class TimeUtils {
    public static String secToTime(int seconds) {
        int hour = seconds / 3600;
        int minute = (seconds - hour * 3600) / 60;
        int second = (seconds - hour * 3600 - minute * 60);

        StringBuilder sb = new StringBuilder();
        if (hour > 0) {
            sb.append(hour).append("小时");
        }
        if (minute > 0) {
            sb.append(minute).append("分");
        }
        if (second > 0) {
            sb.append(second).append("秒");
        }
        if (second == 0) {
            sb.append("0秒");
        }
        return sb.toString();
    }
}
